import React, { memo, useState,useEffect } from 'react'

const App = memo(() => {
  const [counter, setCounter] = useState(100)

  function changTitle () {
    setCounter(counter + 1)
  }
  useEffect(() => {
    document.title = counter
    // 返回值 是一个回调函数 ，在组件重新渲染或者卸载时执行
    return () => { 
      console.log('组件卸载或者重新渲染时执行');
    } 
  }, [counter])
  return (
    <div>
      <h1>App： counter-{counter}</h1>
      <button onClick={() => changTitle()}>+1</button>
    </div>
  )
})

export default App